<extend name="./Public/main" />
<block name="main">
<div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <a href="javascript:;" onclick="addShow(0)"><h5><i class="glyphicon glyphicon-plus" aria-hidden="true"></i>添加顶级菜单</h5></a>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>

                                        <th></th>
                                        <th>菜单名</th>
                                        <th>链接</th>
                                        <th>是否显示</th>
                                        <th>排序</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <volist name="category_list" id="vo">
                                    <tr>
                                        <td>
                                            <div class="icheckbox_square-green checked" style="position: relative;"><input type="checkbox" checked="" class="i-checks" name="input[]" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins></div>
                                        </td>
                                        <td>{$vo['delimiter']} {$vo['title']}</td>
                                        <td>{$vo['url']}</td>
                                        <td>
                                          <if condition="$vo['status'] eq 1">
                                                                                                   显示
                                          <else />
                                                                                                  隐藏
                                          </if>
                                        </td>
                                        <td>{$vo['sort']}</td>
                                        <td>
                                            <a href="javascript:;" onclick="addShow({$vo.id})" title="增加子分类" style="margin-right:10px" title="添加子菜单"><i class="glyphicon glyphicon-plus" aria-hidden="true"></i></a>
                                            <a href="javascript:;" onclick="editAlert({$vo.id})" title="修改" style="margin-right:10px"><i class="glyphicon glyphicon-edit"></i></a>
                                            <a href="javascript:;" onclick="delAlert({$vo.id})"  title="删除"><i class="glyphicon glyphicon-trash"></i></a>
                                        </td>
                                    </tr>
                                    </volist>
                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            </div>

        </div>
        <!-- 添加弹出框开始 -->
        <div id="AddAlert" style="display:none;position:absolute;left:0px;top:0px;z-index:9999;background:rgba(198,198,198,0.5);width:100%;height:100%">
	        <div class="col-sm-6" style="margin-left:470px;margin-top:270px">
	                <div class="ibox float-e-margins">
	                    <div class="ibox-title">
	                        <h5>添加菜单</h5>
	                        <div class="ibox-tools">
	                            <a class="close-link" onclick="addClose()">
	                                <i class="fa fa-times"></i>
	                            </a>
	                        </div>
	                    </div>
	                    <div class="ibox-content">
	                        <div class="row">
	                            <div class="col-sm-12">
	                                <form role="form" action="{:U('SystemList/insert')}" method="post">
	                                    <input type="hidden" name="parent_id">
	                                    <div class="form-group">
	                                        <label>菜单名</label>
	                                        <input type="text" placeholder="主页" name="title" class="form-control">
	                                    </div>
	                                    <div class="form-group">
	                                        <label>地址</label>
	                                        <input type="text" placeholder="例：Admin/Index/index" name="url" class="form-control">
	                                    </div>
                                        <div class="form-group">
	                                      <label >排序：</label>&nbsp&nbsp&nbsp&nbsp
                                             <input type="text" placeholder="排序" name="sort" class="form-control">
                                        </div>
                                        <div class="form-group">
	                                      <label >是否显示：</label>&nbsp&nbsp&nbsp&nbsp
                                            <input type="radio" checked value="1" id="optionsRadios1" name="status">显示&nbsp&nbsp&nbsp&nbsp
                                            <input type="radio" value="0" id="optionsRadios1" name="status">隐藏
                                        </div>
	                                    <div>
	                                        <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" style="margin-right:450px">
	                                           <strong>添加</strong>
	                                        </button>
	                                        
	                                    </div>
	                                </form>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
            </div>
        <!-- 添加弹出框结束 -->
        
        <!-- 修改弹出框开始 -->
        <div id="editAlert" style="display:none;position:absolute;left:0px;top:0px;z-index:9999;background:rgba(198,198,198,0.5);width:100%;height:100%">
	        <div class="col-sm-6" style="margin-left:470px;margin-top:270px">
	                <div class="ibox float-e-margins">
	                    <div class="ibox-title">
	                        <h5>修改菜单</h5>
	                        <div class="ibox-tools">
	                            <a class="close-link" onclick="editClose()">
	                                <i class="fa fa-times"></i>
	                            </a>
	                        </div>
	                    </div>
	                    <div class="ibox-content">
	                        <div class="row">
	                            <div class="col-sm-12">
	                                <form role="form" action="{:U('SystemList/insert')}" method="post">
	                                    <input type="hidden" name="id">
	                                    <input type="hidden" name="parent_id">
	                                    <div class="form-group">
	                                        <label>菜单名</label>
	                                        <input type="text"  name="title" class="form-control">
	                                    </div>
	                                    <div class="form-group">
	                                        <label>地址</label>
	                                        <input type="text"  name="url" class="form-control">
	                                    </div>
                                        <div class="form-group">
	                                      <label >排序：</label>&nbsp&nbsp&nbsp&nbsp
                                             <input type="text"  name="sort" class="form-control">
                                        </div>
                                        <div class="form-group">
	                                      <label >是否显示：</label>&nbsp&nbsp&nbsp&nbsp
                                            <input type="radio" value="1" name="status">显示&nbsp&nbsp&nbsp&nbsp
                                            <input type="radio" value="0"  name="status">隐藏
                                        </div>
	                                    <div>
	                                        <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" style="margin-right:450px">
	                                           <strong>添加</strong>
	                                        </button>
	                                        
	                                    </div>
	                                </form>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
            </div>
        <!-- 修改弹出框结束 -->
        <script>
            function addShow(pid){
            	$("#AddAlert input[name='parent_id']").val(pid);
            	$("#AddAlert").css("display","block");
            }
            function addClose(){
            	$("#AddAlert").css("display","none");
            }
            function delAlert(id){
            	layer.confirm('确认删除', {
            		  btn: ['确定','取消'] //按钮
            		}, function(){
            			var str = "{:U('SystemList/del',array('id'=>seatId))}";
            			var url = str.replace("seatId",id)
            			location.href = url;
            		}, function(){
            			
            		});
            }
            function editClose(){
            	$("#editAlert").css("display","none");
            }
            function editAlert(id){
            	$("#editAlert").css("display","block");
            	$.ajax({
            		url: "{:U('SystemList/update')}",
            		data:{id:id},
            		type:"post",
            		dataType:'json',
            		success:function(res){
            			if(res.status == 1){
            				$("#editAlert input[name='id']").val(id);
            				$("#editAlert input[name='parent_id']").val(res.arr.parent_id);
                			$("#editAlert input[name='title']").val(res.arr.title);
                			$("#editAlert input[name='url']").val(res.arr.url);
                			$("#editAlert input[name='sort']").val(res.arr.sort);
                			if(res.arr.status == 1){
                				$("#editAlert input[name='status'][value='1']").attr('checked','checked');
                			}else{
                				$("#editAlert input[name='status'][value='0']").attr('checked','checked');
                			}
            			}else{
            				layer.msg(res.info);
            			}
            			
            		},
            	})
            }
        </script>
</block>